package org.projecteboot.compent.core.utils;

import com.google.gson.Gson;

import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author LuoQiang
 * @date 2019/8/30 12:38
 **/
public class JsonUtil {
    public static <T> T str2Obj(String str, Class<T> clz) {
        for(int i=0;i<str.length();i++){
            System.out.println(i+"  "+str.charAt(i));
        }
        T t = new Gson().fromJson(str, clz);
        return t;
    }

    public static void main(String[] args) {
        String x="m\\.235zw\\.com/19/19028/";
        String a="{'url':'m\\.235zw\\.com/19/19028(_\\d+)?/','weight':'0x80000000'}";
        String aaa = a.replaceAll("\\\\", "\\\\\\\\");
        Map map = str2Obj(aaa, Map.class);
        String url = MapUtil.getMapValue(map, "url");
        Pattern compile = Pattern.compile(url);
        Pattern compile1 = Pattern.compile(x);
        Pattern compile2 = Pattern.compile("m\\.235zw\\.com/book/19/19028/");
        Matcher matcher = compile.matcher("m.235zw.com/19/19028/");
        boolean matches = matcher.matches();
        boolean matches1 = compile1.matcher("m.235zw.com/19/19028/").matches();
        boolean matches2 = compile2.matcher("m.235zw.com/19/19028/").matches();
        System.out.println(matches);
    }
}
